package com.example.date;

import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.TemporalAccessorUtil;
import org.junit.Test;

import java.time.Duration;
import java.time.LocalDate;
import java.time.Period;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalAccessor;
import java.util.Date;

/**
 * @author csp 2024-06-15
 */
public class DateTest {

    @Test
    public void test1() {
        LocalDate now = LocalDate.now();
        Date convert = Convert.convert(Date.class, now);
        System.out.println(convert);
    }

    @Test
    public void test2() {
        LocalDate date1 = LocalDate.parse("2024-06-01");
        LocalDate date2 = LocalDate.parse("2024-06-09");
        long days= Period.between(date1, date2).get(ChronoUnit.DAYS);
        System.out.println(TemporalAccessorUtil.between(date1, date2, ChronoUnit.DAYS));
        System.out.println(days);
    }

    @Test
    public void test3() {
        LocalDate date1 = LocalDate.parse("2024-06");
        System.out.println(date1);
    }

}
